package sury.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sury.biz.service.ApplicationFormService;
import sury.dal.dto.ApplicationFormDTO;
import sury.dal.entity.ApplicationFormEntity;
import sury.dal.mapper.ApplicationFormMapper;

import java.time.LocalDateTime;

@Service
public class ApplicationFormServiceImpl extends ServiceImpl<ApplicationFormMapper, ApplicationFormEntity> implements ApplicationFormService {
    @Autowired
    private ApplicationFormMapper applicationFormMapper;

    @Override
    public Page<ApplicationFormEntity> pageUser(ApplicationFormDTO applicationFormDTO) {
        Page<ApplicationFormEntity> page=new Page<>(applicationFormDTO.getCurrent(),applicationFormDTO.getSize());
        String userName= applicationFormDTO.getUserName();
        Integer status=applicationFormDTO.getStatus();
        LocalDateTime createTime=applicationFormDTO.getCreateTime();
        return page(page,new QueryWrapper<ApplicationFormEntity>()
                .like(userName!=null&&!userName.isEmpty(),"userName",userName)
                .eq(status!=null,"status",status)
                .eq(createTime!=null,"createTime",createTime));
    }
}
